<template>
    <div>
<h1>权益修改</h1>
<table class="table">
    <tbody>
        <tr>
            <td>权益名称</td>
            <td><input type="text" v-model="data.qyName"></td>
        </tr>

        <tr>
            <td>权益状态</td>
            <td>
               <input type="radio" :value="true" v-model="data.qyState">启用
               <input type="radio" :value="false" v-model="data.qyState">禁用
            </td>
        </tr>

        <tr>
            <td></td>
            <td>
                <input type="button" value="修改" @click="xiu">
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>


<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRouter,useRoute } from 'vue-router';
const route=useRoute()
const router=useRouter()
onMounted(()=>{
    fan()
})

const data=ref({
  "qId": 0,
  "qyName": "",
  "qyState": null,
})

//反填
const fan=()=>{
    var dd=route.query.id
    axios.get("https://localhost:7127/api/Qy/FanQy",{params:{id:dd}}).then(res=>{
        data.value=res.data
    })
}

const xiu=()=>{
    axios.put("https://localhost:7127/api/Qy/XiuQy",data.value).then(res=>{
   if(res.data==-1){
    alert("权益已存在")
    return
   }
       
   if(res.data>0){
    alert("修改成功")
    router.push({path:'/showqy'})
   }else{
    alert("修改失败")
   }
    })
}
</script>

<style scoped>

</style>